# -*- coding:utf-8 -*-
# --author： jingfeng 
# time: 2019/2/20


"""

获取图片url  需要调用selenium
"""

import requests
from pyquery import PyQuery as pq

url = 'https://ac.qq.com/Comic/all/state/pink/search/time/vip/1/page/1'
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) '
                  'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36',

}
response = requests.get(url=url,headers=headers)
#
#
# dot = pq(response.text)
#
# lis = dot('.ret-search-result ul li').items()
# for li in lis:
#     # print(li)
#     "名字  作者  类型 人气 阅读链接"
#     picture_url =li('.ret-works-cover a img').attr('data-original')
#
#     title =li('.ret-works-info h3 a').text()
#     author = li('.ret-works-author').text()
#     tag =li('.ret-works-tags a').text()
#     people =li('.ret-works-tags span em').text()
#     url =li('.ret-works-view').attr('href')
#
#     next_url = 'https://ac.qq.com'+url
#     print(next_url)
    # print('555555555555555555')

next_url = 'https://ac.qq.com/Comic/comicInfo/id/639192'
response = requests.get(url=next_url,headers=headers)
#print(response.text)
dot = pq(response.text)

ps=dot('.chapter-page-new li p').items()

for p in ps:
    for span in p('p span').items():
        name = span('span a').text()
        url = span('span a').attr('href')
        print(name,url)

picture_url = 'https://ac.qq.com/ComicView/index/id/639192/cid/13'
from selenium import webdriver

opt=webdriver.ChromeOptions()
opt.set_headless()
browser =webdriver.Chrome(options=opt)
browser.get(picture_url)
import time
time.sleep(5)
print(browser.page_source)
